package com.feifan.monthhelper.db;

import android.arch.persistence.room.Room;
import android.content.Context;

public class DBInstance {
    private static final String DB_NAME = "db_name_1";
    private static AppDataBase appDataBase;

    public static AppDataBase getInstance(Context context) {
        if (appDataBase == null) {
            synchronized (DBInstance.class) {
                if (appDataBase == null) {
                    return Room.databaseBuilder(context, AppDataBase.class, DB_NAME)
//                            .addMigrations(AppDataBase.MIGRATION_1_2)
//                            .addMigrations(AppDataBase.MIGRATION_2_3)
                            .fallbackToDestructiveMigration()
                            .allowMainThreadQueries()
                            .build();
                }
            }
        }
        return appDataBase;
    }
}
